package de.hs_zigr.inf.iib08gruppe5powerfish.it.boundary;

import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;



/**
 * to highlight item on mouse-over and for showing them in
 * guiQueryProg.TexttAreaInput
 */
public class MyMouseAdapter extends MouseAdapter {

	private GUIQueryProg guiQueryProg;
	private GUIListOfQueries guiListOfQueries;

	public MyMouseAdapter(GUIQueryProg guiQueryProg,
			GUIListOfQueries guiListOfQueries) {
		this.guiQueryProg = guiQueryProg;
		this.guiListOfQueries = guiListOfQueries;
	}

	/**
	 * highlights item on mouse-over and show them in
	 * guiQueryProg.TexttAreaInput
	 */
	public void mouseMoved(MouseEvent me) {
		Point p = new Point(me.getX(), me.getY());
		// guiListOfQueries.lstQueries.setSelectedIndex(guiListOfQueries.lstQueries.locationToIndex(p));
		guiListOfQueries.getLstQueries().setSelectedIndex(
				guiListOfQueries.getLstQueries().locationToIndex(p));
		// show highlighted element in tAreaInput
		String arg0 = (String) guiListOfQueries.getLstQueries()
				.getSelectedValue();
		guiQueryProg.setTexttAreaInput("");
		guiQueryProg.setTexttAreaInput(arg0);
	}
}
